from urllib.request import urlopen
from bs4 import BeautifulSoup

print("请输入")
name = input()
print(name)
arr = []
#html = urlopen("http://read.qidian.com/chapter/dVQvL2RfE4I1/hJBflakKUDMex0RJOkJclQ2.html")
html = urlopen("https://read.qidian.com/chapter/dVQvL2RfE4I1/ztyBLQetuH8ex0RJOkJclQ2")
bsObj = BeautifulSoup(html, "html.parser")
# firstChapter2 = bsObj.find("div", {"class", "read-content"})
firstChapter = bsObj.find_all('a', attrs={"id": "j_chapterNext"})
print (firstChapter)
# for k in firstChapter:
#     arr.append('http:'+k['href'])
# for num in range(0, 3):
#     print("正在获取第"+str(num+1)+"个链接")
#     html2 = urlopen(arr[num])
#     aa = BeautifulSoup(html2, "html.parser")
#     firstChapter2 = aa.find("div", {"class", "read-content"})
#     bb = aa.find_all('a', attrs={"id": "j_chapterNext"})
#     print("开始写入内容"+str(num+1)+"的链接内容")
#     with open(r"F:\PhyWorkSpeace\aaa.txt", "a") as file:
#         file.write(firstChapter2.get_text() + '\n')
#     for n in bb:
#         arr.append('http:' + n['href'])
# for m in arr:
#     print(m)
    #file.write("http://www.jianshu.com" + firstChapter.get('href') + '\n\n')
